package com.yuneec.droneservice.parse;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * @author jw.gu
 * @version 1.0
 */
public class MissionFeedback implements Parcelable {
    public int actionType;
    public int missionStatus;
    public int value;
    public boolean isFlying;
    public boolean isLock;
    public int panAngle;
    public int tiltAngle;

    public MissionFeedback() {

    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(actionType);
        dest.writeInt(missionStatus);
        dest.writeInt(value);
        dest.writeInt(isFlying ? 1 : 0);
        dest.writeInt(isLock ? 1 : 0);
        dest.writeInt(panAngle);
        dest.writeInt(tiltAngle);
    }

    public MissionFeedback(Parcel source) {
        actionType = source.readInt();
        missionStatus = source.readInt();
        value = source.readInt();
        isFlying = source.readInt() == 1;
        isLock = source.readInt() == 1;
        panAngle = source.readInt();
        tiltAngle = source.readInt();
    }

    public static final Creator<MissionFeedback> CREATOR = new Creator<MissionFeedback>() {

        @Override
        public MissionFeedback createFromParcel(Parcel source) {
            return new MissionFeedback(source);
        }

        @Override
        public MissionFeedback[] newArray(int size) {
            return new MissionFeedback[size];
        }
    };

    public void readFromParcel(Parcel source) {
        actionType = source.readInt();
        missionStatus = source.readInt();
        value = source.readInt();
        isFlying = source.readInt() == 1;
        isLock = source.readInt() == 1;
        panAngle = source.readInt();
        tiltAngle = source.readInt();
    }

    @Override
    public String toString() {
        return "MissionFeedback{" +
                "actionType=" + actionType +
                ", missionStatus=" + missionStatus +
                ", value=" + value +
                ", isFlying=" + isFlying +
                ", isLock=" + isLock +
                ", panAngle=" + panAngle +
                ", tiltAngle=" + tiltAngle +
                '}';
    }
}
